import React from 'react';
import {useSearchParams} from "react-router-dom";

function Detail(props) {

    const [search,setSearch]=useSearchParams()

    const id=search.get('id')
    const title=search.get('title')
    const content=search.get('content')


    // 通过setSearch修改传过来的search参数
    function changeData(){
        setSearch('id=008&title=消息4&content=哈哈')
    }

    return (
        <div>
            <button onClick={changeData}>点我修改数据</button>
            <ul>
                <li>ID:{id}</li>
                <li>title:{title}</li>
                <li>content:{content}</li>
            </ul>
        </div>
    );
}

export default Detail;